Skip to content

Native PHP worker pool on all platforms#3602

Merged
fredrikekelund merged 27 commits into
trunkfrom
add-native-php-worker-pool-poc
Jun 2, 2026
Merged

Native PHP worker pool on all platforms#3602
fredrikekelund merged 27 commits into
trunkfrom
add-native-php-worker-pool-poc

Conversation

@bcotrim
Copy link
Copy Markdown
Contributor

@bcotrim bcotrim commented May 22, 2026

Related issues

  • Fixes #

How AI was used in this PR

Proposed Changes

Using PHP_CLI_SERVER_WORKERS for concurrency is only supported on macOS and Linux. We want concurrency on Windows, too. This PR accomplishes that by implementing a Node.js HTTP load balancer that proxies requests to a fixed pool of 4 php -S processes. This works surprisingly well in our testing.

In our benchmarks, this solution yields ~30% performance improvement on Windows compared to Playground.

Testing Instructions

CI should pass

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@bcotrim bcotrim self-assigned this May 22, 2026
Comment thread apps/cli/php-server-child.ts Fixed
Comment thread apps/cli/php-server-child.ts Fixed
bcotrim and others added 3 commits May 28, 2026 18:58
… through a stack trace'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@fredrikekelund fredrikekelund changed the title Add native PHP worker pool POC Native PHP worker pool on all platforms May 29, 2026
@fredrikekelund fredrikekelund marked this pull request as ready for review May 29, 2026 16:00
@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented May 29, 2026

📊 Performance Test Results

Comparing c829764 vs trunk

app-size

Metric trunk c829764 Diff Change
App Size (Mac) 1329.72 MB 1329.73 MB +0.01 MB ⚪ 0.0%

site-editor

Metric trunk c829764 Diff Change
load 1649 ms 1659 ms +10 ms ⚪ 0.0%

site-startup

Metric trunk c829764 Diff Change
siteCreation 9013 ms 8993 ms 20 ms ⚪ 0.0%
siteStartup 4402 ms 4383 ms 19 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@bcotrim bcotrim requested a review from fredrikekelund May 31, 2026 07:33
Copy link
Copy Markdown
Contributor

@fredrikekelund fredrikekelund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 @bcotrim and I worked on this side by side at our meetup last week. Benchmark-wise, we concluded that there's no noticeable drawback to this approach compared to PHP_CLI_SERVER_WORKERS, so we're going with this "poor man's php-fpm" approach on all platforms

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this file fix RSM-3965

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this file and in .buildkite/pipeline.yml serve to collect all site logs when an E2E test fails. Site logs are typically forwarded to the main process anyway, but this seems like a sensible thing to keep as the default. It will only make debugging easier

@fredrikekelund
Copy link
Copy Markdown
Contributor

The Linux E2E breakage seems to be CI specific and it exists on trunk, too. I'm proceeding to merge this PR

@fredrikekelund fredrikekelund merged commit ddc9765 into trunk Jun 2, 2026
12 of 13 checks passed
@fredrikekelund fredrikekelund deleted the add-native-php-worker-pool-poc branch June 2, 2026 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants